<template>
	<view class="box w100 min100">
		<u-tabs-swiper ref="tabs" :list="tabslist" :current="current" bg-color="#00C28E" inactive-color="#EEEEEE"
		 active-color="#fff" :is-scroll="false" @change="tabsChange"></u-tabs-swiper>
		<empty v-if="list.length==0" text="暂无优惠券"></empty>
		<view class="list ptb-30 plr-25 mlr-36 mt-30 bg-white radius-10" v-for="(item,i) in list" :key="i">
			<view class="img">
				<image :src="current==0?img1:current==1?img2:img3" mode=""></image>
			</view>
			<view class="flex">
				<view class="">
					<text :class="[current==2?'gray-2':'red','mr-20']">{{item.coupon_name*1==1?'新手券':'福利券'}}</text>
					{{item.remark}}
				</view>
				<view :class="[current==2?'gray-2':'red','mr-20']">
					<text class="size-26">￥</text><text class="size-50">{{item.coupon_price}}</text>
				</view>
			</view>
			<view class="flex">
				<view class="size-26 gray-2 mt-15">
					截止时间: {{item.expiration}}
				</view>
				<view class="size-26 gray-2">
					满{{item.limit_price*1}}使用
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				tabslist: [{
					name: '未使用'
				}, {
					name: '已使用'
				}, {
					name: '已过期'
				}],
				current: 0,
				list: [],
				img1:'../../../static/coupon-1.png',
				img2:'../../../static/coupon-2.png',
				img3:'../../../static/coupon-3.png'
			}
		},
		onLoad() {
			this.init()
		},
		methods: {
			tabsChange(e) {
				this.current = e
				this.init()
			},
			init() {
				this.$http('/addons/ddrive/user/coupon', {
					type: this.current + 1
				}, "POST").then(data => {
					console.log(data);
					this.list = data
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.box {
		background: #F8F8F8;
		overflow: hidden;
	}

	.list {
		position: relative;
	}
	.img{
		width: 80rpx;
		height: 80rpx;
		position: absolute;
		right: 10rpx;
		top: 10rpx;
		image{
			width: 100%;
			height: 100%;
		}
	}
	.list::before {
		position: absolute;
		content: "";
		width: 36rpx;
		height: 36rpx;
		border-radius: 50%;
		background: #f8f8f8;
		margin-top: -18rpx;
		top: 50%;
		left: -18rpx;
	}

	.list::after {
		position: absolute;
		content: "";
		width: 36rpx;
		height: 36rpx;
		border-radius: 50%;
		background: #f8f8f8;
		margin-top: -18rpx;
		top: 50%;
		right: -18rpx;
	}
</style>
